/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.proyectos.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

/**
 *
 * @author jose
 */
@Entity
@NamedQueries({
    @NamedQuery(name="alumnos.findByName",query="SELECT c FROM alumnos c WHERE upper(c.cnombre) like :cnombre and c.ncarrera =   :ncarrera "),
    @NamedQuery(name="alumnos.findByNameAmin",query="SELECT c FROM alumnos c WHERE (upper(c.cnombre) like :cnombre )or (upper(c.capellidos) like :cnombre)"),
    @NamedQuery(name="alumnos.findAll", query="SELECT c FROM alumnos c where c.ncarrera = :ncarrera "),
    @NamedQuery(name = "alumnos.findByCodigo", query = "SELECT c FROM alumnos c WHERE upper(c.ccodigo) = :ccodigo and c.ncarrera =   :ncarrera")})
public class alumnos implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private BigDecimal ncodigo;
    @Column
    private String cnombre;
    @Column
    private String capellidos;
    @Column
    private String cdireccion;
    @Column
    private String ctelefono;
    @Column
    private String cmail;
    @Column
    private String ccodigo;
    
    @ManyToOne
    @JoinColumn(name="ncarrera")
    private Carreras ncarrera;
    @Column
    private String cpassword;

    public String getCpassword() {
        return cpassword;
    }

    public void setCpassword(String cpassword) {
        this.cpassword = cpassword;
    }
    public Carreras getNcarrera() {
        return ncarrera;
    }

    public void setNcarrera(Carreras ncarrera) {
        this.ncarrera = ncarrera;
    }

    public String getCcodigo() {
        return ccodigo;
    }

    public void setCcodigo(String ccodigo) {
        this.ccodigo = ccodigo;
    }
    

    public BigDecimal getNcodigo() {
        return ncodigo;
    }

    public void setNcodigo(BigDecimal ncodigo) {
        this.ncodigo = ncodigo;
    }

    public String getCnombre() {
        return cnombre;
    }

    public void setCnombre(String cnombre) {
        this.cnombre = cnombre;
    }

    public String getCapellidos() {
        return capellidos;
    }

    public void setCapellidos(String capellidos) {
        this.capellidos = capellidos;
    }

    public String getCdireccion() {
        return cdireccion;
    }

    public void setCdireccion(String cdireccion) {
        this.cdireccion = cdireccion;
    }

    public String getCtelefono() {
        return ctelefono;
    }

    public void setCtelefono(String ctelefono) {
        this.ctelefono = ctelefono;
    }

    public String getCmail() {
        return cmail;
    }

    public void setCmail(String cmail) {
        this.cmail = cmail;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 11 * hash + Objects.hashCode(this.ccodigo);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final alumnos other = (alumnos) obj;
        if (!Objects.equals(this.ccodigo, other.ccodigo)) {
            return false;
        }
        return true;
    }

   public String getNombre()
   {
       return this.capellidos+", "+this.cnombre;
   }
    
    
}
